package com.excel.analysis;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ExpressionUtils {

	public static boolean expression(String reg, String value) {
		Pattern p = Pattern.compile(reg);
		Matcher m = p.matcher(value);
		return m.find();
	}

	public static boolean isHeader(String value) {
		return ExpressionUtils.expression("^#\\{page_header}#$", value);
	}

	public static boolean isEndHeader(String value) {
		return ExpressionUtils.expression("^#\\/\\{page_header}#$", value);
	}

	public static boolean isFooter(String value) {
		return ExpressionUtils.expression("^#\\{footer}#$", value);
	}

	public static boolean isEndFooter(String value) {
		return ExpressionUtils.expression("^#\\/\\{footer}#$", value);
	}

	public static boolean isHeaderLabel(String value) {
		return ExpressionUtils.expression("^#\\{label:.+\\}#$", value);
	}

	public static boolean isHeaderVar(String value) {
		return ExpressionUtils.expression("^#\\{vars:.+\\}#$", value);
	}

	public static boolean isHeaderEndVar(String value) {
		return ExpressionUtils.expression("^#\\/\\{vars:.+\\}#$", value);
	}

	public static boolean isUserDefine(String value) {
		return ExpressionUtils.expression("^#\\{user_define\\}#$", value);
	}

	public static boolean isEndUserDefine(String value) {
		return ExpressionUtils.expression("^#\\/\\{user_define\\}#$", value);
	}

	public static boolean isCPQ(String value) {
		return ExpressionUtils.expression("^#\\{cpq\\}#$", value);
	}

	public static boolean isEndCPQ(String value) {
		return ExpressionUtils.expression("^#\\/\\{cpq\\}#$", value);
	}

	public static boolean isTitleBar(String value) {
		return ExpressionUtils.expression("^#\\{titleBar\\}#$", value);
	}

	public static boolean isEndTitleBar(String value) {
		return ExpressionUtils.expression("^#\\/\\{titleBar\\}#$", value);
	}

	public static boolean isCpqArea(String value) {
		return ExpressionUtils.expression("^#\\{cpqArea\\}#$", value);
	}

	public static boolean isEndCpqArea(String value) {
		return ExpressionUtils.expression("^#\\/\\{cpqArea\\}#$", value);
	}

	public static boolean isKpi(String value) {
		return ExpressionUtils.expression("^#\\{kpi:.+\\}#$", value);
	}

	public static boolean isEntry(String value) {
		return ExpressionUtils.expression("^#\\{entry:.+\\}#$", value);
	}

	public static boolean isField(String value) {
		return ExpressionUtils.expression("^#\\{field:.+#$", value);
	}

	public static void main(String[] args) {
		System.out.println(ExpressionUtils.expression("^#\\{label:.+\\}#$",
				"#{label:内蒙邮政储蓄营业网点调查问卷}#"));
	}
}
